import { RequestNet } from '../common/net';
import { WorkItem } from '../item/component';

// 获取事务和事务项信息 (Auth)
export const GetPWorkItemComInfo = (verId: string) => {
  return RequestNet<WorkItem[]>({
    url: '/api/Tim/GetPWorkItemComInfo',
    params: { form_ver_id: verId },
  });
};

// 添加记录单事务信息 (Auth)
// {"FORM_VER_ID":"记录单版本ID","WORK_NAME":"事务名称","WORK_NO":"事务编号"}
export const InsertWorkInfo = (params: { FORM_VER_ID: string; WORK_NAME: string; WORK_NO: string }) => {
  return RequestNet<any[]>({
    url: '/api/Tim/InsertWorkInfo',
    method: 'post',
    data: JSON.stringify(params),
    // params: { form_ver_id: verId },
  });
};

// {"WORK_ID":"4","ITEM_ID":"" "BOOKMARK":"CO_001@□正常 □不正常@0, 0###CO_002@□正常 □不正常@0, 0###EO_004@仪器已设自动开机, 打开主机计算机屏幕 → 打开中文计算机电源@0, 0###PO_003@@0, 0###SO_001@1.检查水源并打开净水仪贮水容器的出水阀门（制水开关及纯水开关）。@0, 0###SO_002@2.检查水质。@0, 0###SO_003@3.急啊卡了巨大@0, 0###SO_004@4.普朗克CPA@0, 0###"}
export const InsertworkItemInfo = (params: { WORK_ID: string; ITEM_ID: string; BOOKMARK: string }) => {
  return RequestNet<any[]>({
    url: '/api/Tim/InsertworkItemInfo',
    method: 'post',
    data: JSON.stringify(params),
    // params: { form_ver_id: verId },
  });
};

// 保存事务项信息 (Auth)
// {"WORK_ID":"事务ID","ITEM_ID":"事务项ID(添加为空)","ITEM_CODE":"书签名","ITEM_SORT":"排序号","ITEM_CNAME":"名称","ITEM_BOOKMARK":"坐标"}
export const SaveWorkItemOperate = (params: {
  WORK_ID: string;
  ITEM_ID?: string;
  ITEM_CODE: string;
  ITEM_SORT: string;
  ITEM_CNAME: string;
  ITEM_BOOKMARK: string;
}) => {
  return RequestNet<any[]>({
    url: '/api/Tim/SaveWorkItemOperate',
    method: 'post',
    data: JSON.stringify(params),
    // params: { form_ver_id: verId },
  });
};

// 删除事务事务项 (Auth)
// {"TYPE":"(0删除事务1删除事务项)","WORK_ID":"","ITEM_IDS":""}
export const WorkItemDelete = (params: { TYPE: string; WORK_ID: string; ITEM_IDS: string[] }) => {
  return RequestNet<any[]>({
    url: '/api/Tim/WorkItemDelete',
    method: 'post',
    data: JSON.stringify(params),
    // params: { form_ver_id: verId },
  });
};

// 获取数据项信息 (Auth)
export const GetDataItemInfo = () => {
  return RequestNet<any[]>({
    url: '/api/Tim/GetDataItemInfo',
  });
};

// 获取事务项引用体系文档信息 (Auth)
export const GetTimQuoteSysDocInfo = (class_id: string, doc_name: string) => {
  return RequestNet<any[]>({
    url: '/api/Dmis/GetTimQuoteSysDocInfo',
    params: { class_id, doc_name },
  });
};

export const GetHeaderInfo = (pgroup_id: string, browse_type: string) => {
  return RequestNet<any[]>({
    url: '/api/Tim/GetHeaderInfo',
    params: { pgroup_id, browse_type },
  });
};

// /api/Dmis/GetSysDocClassInfo
export const GetSysDocClassInfo = () => {
  return RequestNet<any[]>({
    url: '/api/Dmis/GetSysDocClassInfo',
  });
};

// browse_type: 1 docx, 2 pdf
export const GetWorkFormVerFile = (browse_type: string, form_ver_id: string) => {
  return RequestNet<any[]>({
    url: '/api/Tim/GetWorkFormVerFile',
    params: { browse_type, form_ver_id },
  });
};

// 根据事务获取最新事务项名称 (Auth)
export const GetLatestItemCode = (form_ver_id: string) => {
  return RequestNet<string>({
    url: '/api/Tim/GetLatestItemCode',
    params: { form_ver_id },
  });
};
